<?php
namespace app\admin\controller;

class GlobalSet extends Base{
    //
    protected function initialize() {
        parent::initialize();
        $this->model = 'GlobalSet';
    }
    //
    protected function _before_index(){
        $thead = [
            'gsid' => 'GSID',
            'cname' => '中文名称',
            'key' => '字段键名',
            'value' => '字段键值',
            'desc' => '说明信息',
            'addtime' =>'创建时间',
        ];
        $this->assign('thead', $thead);
    }
    //
    protected function _filter($map){
        return $map;
    }
    //
    protected function _after_list($list){
        foreach($list as $key => $row){
            $list[$key]['addtime'] = date('Y-m-d H:i:s', $row['addtime']);
        }
        return $list;
    }
    //
    protected function _before_add(){}
    //
    protected function _before_insert($data){
        $data['addtime'] = time();
        return $data;
    }
    //
    protected function _after_add($data, $lastid){
        $this->log(['pk' => 'gsid', 'value' => $lastid], $data);
    }
    //
    protected function _before_edit(){}
    //
    protected function _filter_edit($list){
        return $list;
    }
    //
    protected function _before_save($data){
        return $data;
    }
    //
    protected function _after_edit($data){
        $this->log(['pk' => 'gsid', 'value' => $data['gsid']], $data);
    }
    //
    protected function _filter_del(){
        return [1,2,3,4,5,6,7,8,10];
    }
    //
    protected function _after_del($rows){
        $logs = [];
        foreach($rows as $row){
            $logs[] = ['pk' => 'gsid', 'value' => $row['gsid'], 'row' => $row];
        }
        $this->logAll($logs);
    }
}